package com.xxx.controller;

import com.xxx.entity.User;
import com.xxx.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/toAdd")
    public String add(){
        System.out.println("-----method：toAdd");

        return "/user/add";
    }

    @RequestMapping("/toUpdate")
    public String update(){
        System.out.println("-----method：toUpdate");

        return "/user/update";
    }

    /*
     * 方法：查询ID
     * 作用：次方法存在只是测试，方法返回的数据类型的void，可以正常运行，但是Shiro框架配置的原因会造成方法走完后控制层爆出错误提示。(待：了解名称补充)
     * */
    @RequestMapping("/selectId")
    public String selectId(int id){
        System.out.println("ID:" + id);

        User user = new User();
        user = userService.selectId(id);
        System.out.println("ID:" + user.getId());
        System.out.println("userName:" + user.getUsername());
        System.out.println("passWord:" + user.getPassword());
        return null;
    }
}
